import { request } from '@/utils/request'
import type {
  additionalProperties1,
  arrs1,
  obj1,
  obj2,
  arrss1,
  arrss2
} from './types/Applic'
import type { data, dataList } from './types/journey'
//应用分页列表
type ying = {
  category?: string
  name?: string
  theme?: string
}
export const getApps = (params: ying) =>
  request<additionalProperties1>('/api/h5/application/list', 'get', params)
//应用字母分类

export const getAppsByLetter = (params: ying) =>
  request<any>('/api/h5/application/group/list', 'get', params)
//线上单点登录接口
export const ssoLogin = (params: any) =>
  request<obj1>('/redirectLogin', 'get', params)
//本地获取token接口
export const localLogin = () => request<obj2>('/test/redirectLogin', 'get')
//资讯中心
type pars = {
  startTime?: string
  endTime?: string
  page?: number
  pageSize?: number
  title?: string
  typeId?: number
}
export const getNews = (params: pars) =>
  request<arrs1>('/api/news/page', 'get', params)
//资讯分类
export const getTypeList = () => request<arrss1>('/api/news/type/list', 'GET')

//应用主题类别列表
export const getThemeList = (type: number) =>
  request<arrss1>(`/api/app/type/list/${type}`, 'GET')

//应用评价保存
type saveAppComment = {
  appId: string
  fraction: string
}
export const saveAppComment = (data: saveAppComment) =>
  request<any>('/api/evaluation/save', 'POST', data)
//新增收藏接口
type addCollect = {
  appId: string
  appIds: Array<string>
}
export const addCollect = (data: addCollect) =>
  request<any>('/api/h5/app/collection/add', 'POST', data)
//保存收藏列表
type delCollect = {
  data: boolean
}
export const saveCollect = (data: addCollect) => {
  return request<delCollect>('/api/h5/app/collection/save', 'POST', data)
}

//常用应用
export const getCommonlyUsed = (params: any) =>
  request<additionalProperties1>(
    '/api/h5/application/record/list',
    'GET',
    params
  )
//新增使用记录
type addRecord = {
  appId: string
}
export const addRecord = (data: any) =>
  request<any>('/api/h5/application/record/add', 'POST', data)
//主题类别的应用数量统计列表
export const getThemeAppCount = () =>
  request<arrss2>('/api/app/type/count/list', 'GET')

//获取行程配置分页列表
type parsk = {
  page?: number
  pageSize?: number
  xcmc?: string
  xm?: number
}
export const getTravelConfig = (params: parsk) =>
  request<data>('/api/h5/training/xcpz/list', 'get', params)

//修改或新增行程配置
type saveTravelConfig = {
  bz: string
  gh: string
  id?: string
  jsrq: string
  ksrq: string
  xcmc: string
  xm: string
}

export const saveTravelConfig = (data: saveTravelConfig) =>
  request<any>('/api/h5/training/xcpz/commit', 'POST', data)

//获取教师列表
export const getTeacherList = () =>
  request<any>('/api/h5/training/teacher/list', 'GET')
//数据回显
export const Dataecho = (id: any) =>
  request<any>(`/api/h5/training/xcpz/detail/${id}`, 'GET')

//行程配置日程安排列表
export const scheduleList = (xcid: any) =>
  request<dataList>(`/api/h5/training/rcxx/list/${xcid}`, 'GET')

//内容选择列表
export const contentList = (lx: any, params: any) =>
  request<any>(`/api/h5/training/rcxx/${lx}`, 'GET', params)
//场地选择列表
export const siteList = (params: any) =>
  request<any>('/api/h5/training/rcxx/site', 'GET', params)
//行程配置日程安排提交
export const scheduleCommit = (xcid: any, data: any) =>
  request<any>(`/api/h5/training/rcxx/commit/${xcid}`, 'POST', data)
//获取班级列表
export const getClassList = (params: any) =>
  request<any>('/api/h5/training/bj/list', 'GET', params)
//行程配置绑定班级
export const bindClass = (xcid: any, data: any) =>
  request<any>(`/api/h5/training/xcpz/class/${xcid}`, 'POST', data)
//word下载
export const bindClassk = (xcid: any) =>
  request<any>(`/api/h5/training/rcxx/word/${xcid}`, 'GET')
